<!--  -->
<template>
  <div class="card w-100P h-100P" :class="[setColor(colorNumber)]">
    <div class="card-header font-size-14 ">
      更新时间：{{ modelData.createTime | dateTimeFormatter }}
    </div>
    <div class="card-body ">{{ modelData.name }}</div>
    <div class="card-footer justify-between align-center">
      <span>说明：{{modelData.remark||'无'}}</span>
      <div class="button-cantainer flex-row">
        <div @click.stop="seeModelDetail" class="btn-set">查看</div>
        <div @click.stop="handleDelClick" class="btn-set">删除</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ProductCard',
  components: {},

  props: {
    modelData: {
      type: Object,
      default() {
        return {
          id: '',
          date: '2020',
          name: '物模型名称',
        }
      },
    },
    colorNumber: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {}
  },

  computed: {},

  methods: {
    seeModelDetail() {
      this.$router.push({
        path: '/device/thingmodel-detail',
        query: {
          // 参数携带方式
          id: this.modelData.id,
        },
      })
    },
    handleDelClick() {
      this.$confirm('此操作将永久删除该物模型, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.$emit('delClick', this.modelData.id)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除',
          })
        })
    },
    setColor(colorNumber) {
      switch (colorNumber) {
        case 0:
        case 5:
        case 10:
          return 'color0'

        case 1:
        case 6:
        case 11:
          return 'color1'

        case 2:
        case 7:
        case 8:
          return 'color2'

        default:
          return 'color3'
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.card {
  display: flex;
  width: vw(380px);
  height: vw(230px);
  border-radius: 20px 20px 0 0;
  flex-direction: column;
  justify-content: space-between;
}

.card-header {
  padding-top: vh(20px);
  margin-left: vw(20px);
  color: #fefefe;
}

.font-size-14 {
  font-size: vw(14px);
}

.card-body {
  font-size: vw(30px);
  font-weight: 500;
  color: #fefefe;
  text-align: center;
}

.card-footer {
  width: 100%;
  height: vh(52px);
  padding-left: vw(20px);
  font-size: vw(14px);
  line-height: vh(48px);
  color: #fefefe;
}

.btn-set {
  height: vh(34px);
  padding: 0 vh(10px);
  line-height: vh(33px);
  border: 1px solid #fff;
  border-radius: 4px;

  &:hover {
    cursor: pointer;
  }
}

.button-cantainer {
  margin-right: vw(20px);
}

.btn-set + .btn-set {
  margin-left: vw(10px);
}

.color0 {
  background: linear-gradient(45deg, #ff674a 0%, #ffa897 100%);

  .card-footer {
    background: rgba($color: #d12d1f, $alpha: 0.3);
  }
}

.color1 {
  background: linear-gradient(45deg, #42a4ff 0%, #89c3f8 100%);

  .card-footer {
    background: rgba($color: #0051ac, $alpha: 0.3);
  }
}

.color2 {
  background: linear-gradient(45deg, #6b7cf8 0%, #8693f3 100%);

  .card-footer {
    background: rgba($color: #4729b6, $alpha: 0.3);
  }
}

.color3 {
  background: linear-gradient(45deg, #a764ee 0%, #bc8dee 100%);

  .card-footer {
    background: rgba($color: #8117d2, $alpha: 0.3);
  }
}

.button-cantainer {
  float: right;
}

::v-deep {
  .el-button {
    color: white;
    background-color: transparent;
    border: 1px solid white;
  }
}
</style>
